package com.ruoyi.stock.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.stock.domain.TransactionDiscipline;
import com.ruoyi.stock.mapper.TransactionDisciplineMapper;
import com.ruoyi.stock.service.ITransactionDisciplineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 交易纪律Service业务层处理
 *
 * @author ruoyi
 * @date 2025-05-13
 */
@Service
public class TransactionDisciplineServiceImpl implements ITransactionDisciplineService {
    @Autowired
    private TransactionDisciplineMapper transactionDisciplineMapper;

    /**
     * 查询交易纪律
     *
     * @param id 交易纪律主键
     * @return 交易纪律
     */
    @Override
    public TransactionDiscipline selectTransactionDisciplineById(Long id) {
        return transactionDisciplineMapper.selectTransactionDisciplineById(id);
    }

    /**
     * 查询交易纪律列表
     *
     * @param transactionDiscipline 交易纪律
     * @return 交易纪律
     */
    @Override
    public List<TransactionDiscipline> selectTransactionDisciplineList(TransactionDiscipline transactionDiscipline) {
        return transactionDisciplineMapper.selectTransactionDisciplineList(transactionDiscipline);
    }

    /**
     * 新增交易纪律
     *
     * @param transactionDiscipline 交易纪律
     * @return 结果
     */
    @Override
    public int insertTransactionDiscipline(TransactionDiscipline transactionDiscipline) {
        transactionDiscipline.setDate(new Date());
        transactionDiscipline.setCreateTime(DateUtils.getNowDate());
        return transactionDisciplineMapper.insertTransactionDiscipline(transactionDiscipline);
    }

    /**
     * 修改交易纪律
     *
     * @param transactionDiscipline 交易纪律
     * @return 结果
     */
    @Override
    public int updateTransactionDiscipline(TransactionDiscipline transactionDiscipline) {
        return transactionDisciplineMapper.updateTransactionDiscipline(transactionDiscipline);
    }

    /**
     * 批量删除交易纪律
     *
     * @param ids 需要删除的交易纪律主键
     * @return 结果
     */
    @Override
    public int deleteTransactionDisciplineByIds(Long[] ids) {
        return transactionDisciplineMapper.deleteTransactionDisciplineByIds(ids);
    }

    /**
     * 删除交易纪律信息
     *
     * @param id 交易纪律主键
     * @return 结果
     */
    @Override
    public int deleteTransactionDisciplineById(Long id) {
        return transactionDisciplineMapper.deleteTransactionDisciplineById(id);
    }
}
